/**
 * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 *
 * For the applicable distribution terms see the license.txt -file, included in
 * the distribution.
 */

#ifndef AUDIOPLAYER_H
#define AUDIOPLAYER_H

#include <QObject>

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
    #include <QSystemDeviceInfo>
    QTM_USE_NAMESPACE
#endif

#include "GEAudio/GEAudioOut.h"
#include "GEAudio/GEAudioMixer.h"
#include "GEAudio/GEAudioBufferPlayInstance.h"


class AudioPlayer : public QObject
{
    Q_OBJECT

public:
    explicit AudioPlayer(QObject *parent, const QString& url);

public slots:
    void setSpeed(qreal);
    void stop();
    void start();

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
    void profile(QSystemDeviceInfo::Profile profile)
    {
        if (profile == QSystemDeviceInfo::SilentProfile) {
            m_silent = true;
            m_playInstance->setLeftVolume(0);
            m_playInstance->setRightVolume(0);
        }
        else {
            m_silent = false;

            if (m_playing) {
                m_playInstance->setLeftVolume(1);
                m_playInstance->setRightVolume(1);
            }
        }
    }
#endif

private: // Data
    GE::AudioOut *m_audioOut; // Owned
    GE::AudioMixer *m_mixer; // Owned
    GE::AudioBufferPlayInstance *m_playInstance; // Owned by m_mixer
    bool m_silent;
    bool m_playing;
};

#endif // AUDIOPLAYER_H
